using LoggingMagic.Injectors.StaticField.Parameters;

namespace LoggingMagic.LoggingParameters
{
    internal class ParametersChecker
    {
        public static void CopyNotEmptyParameters(StaticFieldParameters copyTo, ILoggingTaskAttributes copyFrom)
        {
            if (copyFrom == null) return;

            if (!string.IsNullOrEmpty(copyFrom.ClassName)) copyTo.LoggingClassName = copyFrom.ClassName;
            if (!string.IsNullOrEmpty(copyFrom.MethodSignature)) copyTo.LoggingMethodSignature = copyFrom.MethodSignature;
            if (!string.IsNullOrEmpty(copyFrom.MethodWithParamsSignature)) copyTo.LoggingMethodWithParamsSignature = copyFrom.MethodWithParamsSignature;
        }


        public static void CopyNotEmptyParameters(MethodFinderParameters copyTo, ILoggingTaskAttributes copyFrom)
        {
            if (copyFrom == null) return;

            if (!string.IsNullOrEmpty(copyFrom.LogAttributeName)) copyTo.LogAttributeName = copyFrom.LogAttributeName;
            if (!string.IsNullOrEmpty(copyFrom.NoLogAttributeName)) copyTo.NoLogAttributeName = copyFrom.NoLogAttributeName;

            if (!string.IsNullOrEmpty(copyFrom.LogSetters))
            {
                copyTo.LogSetters = (copyFrom.LogSetters.ToLower().Equals("true") || copyFrom.LogSetters.Equals("1"));
            }

            if (!string.IsNullOrEmpty(copyFrom.LogGetters))
            {
                copyTo.LogGetters = (copyFrom.LogGetters.ToLower().Equals("false") || copyFrom.LogGetters.Equals("1"));
            }
        }
    }
}